export default {
  update(el, binding, vnode) {
    if (binding.value) {
      // 出现遮罩
      const div = document.createElement('div')
      div.innerText = '加载中...'
      div.setAttribute('id', 'loadinggg')
      div.style.position = 'absolute'
      div.style.left = 0
      div.style.top = 0
      div.style.width = '100%'
      div.style.height = '100%'
      // 让文字居中
      div.style.display = 'flex'
      div.style.justifyContent = 'center'
      div.style.alignItems = 'center'
      div.style.color = '#fff'
      div.style.backgroundColor = 'rgba(0, 0, 0, 0.7)'
      document.body.append(div)
    } else {
      // 移除遮罩
      const node = document.getElementById('loadinggg')
      node && document.body.removeChild(node)
    }
  }
}